package com.project.controller.custom;

import com.project.bean.OrderBean;
import com.project.bean.UserBean;
import com.project.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("custom/order")
public class OrderController {
    @Autowired
    private IOrderService orderService;
    @RequestMapping("addOrder")
    public String addOrder(OrderBean order, HttpServletRequest request){

        //得到登陆信息
        UserBean loginUser = (UserBean)request.getSession()
                .getAttribute("loginUser");
        //添加订单
        orderService.add(order,loginUser.getId());
        return "ok";
    }
}
